﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using l1cs.server.model.Instance;

namespace l1cs.server.serverpackets
{
    public class S_Party : ServerBasePacket
    {
        private byte[] _byte = null;

        public S_Party( String htmlid, int objid )
        {
            buildPacket( htmlid, objid, "", "", 0 );
        }

        public S_Party( String htmlid, int objid, String partyname,
                String partymembers )
        {

            buildPacket( htmlid, objid, partyname, partymembers, 1 );
        }

        private void buildPacket( String htmlid, int objid, String partyname, String partymembers, int type )
        {
            writeC( Opcodes.S_OPCODE_SHOWHTML );
            writeD( objid );
            writeS( htmlid );
            writeH( type );
            writeH( 0x02 );
            writeS( partyname );
            writeS( partymembers );
        }

        override
        public byte[] getContent()
        {
            if ( _byte == null )
            {
                _byte = _bao.ToArray();
            }

            return _byte;
        }

        override
        public String getType()
        {
            return "[S] S_Party";
        }
    }
}